//
//  ProductListCell.m
//  cooba-iOS
//
//  Created by 郭四虎 on 16/4/19.
//  Copyright © 2016年 YouKu. All rights reserved.
//

#import "ProductListCell.h"

@implementation ProductListCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
    
}

- (void)showModel:(ProductModel *)model
{
    NSString *url = [NSString stringWithFormat:@"%@?url=%@",GETICON,model.icon];
    [self.icon sd_setImageWithURL:[NSURL URLWithString:url] placeholderImage:[UIImage imageNamed:@"image1.png"]];
    
    self.name.text = model.name;
    self.desc.text = model.desc;
    self.extype.text = model.ex_type;
//    NSString *parentStr = [NSString stringWithFormat:@"回复%@:%@",model.parent_name,model.content];
//    NSMutableAttributedString * str = [[NSMutableAttributedString alloc]initWithString:parentStr];
//    [str addAttribute:NSForegroundColorAttributeName value:[UIColor blackColor]range:NSMakeRange(0, model.parent_name.length+3)];
    
    NSString *pstr = [NSString stringWithFormat:@"兑换积分：%@",model.integral_num];
    NSMutableAttributedString *nstr = [[NSMutableAttributedString alloc]initWithString:pstr];
    [nstr addAttribute:NSForegroundColorAttributeName value:[UIColor greenColor] range:NSMakeRange(5, model.integral_num.length)];
    self.needNum.attributedText = nstr;
    
    NSString *bstr = [NSString stringWithFormat:@"剩余：%@",model.num];
    NSMutableAttributedString *mstr = [[NSMutableAttributedString alloc]initWithString:bstr];
    [mstr addAttribute:NSForegroundColorAttributeName value:[UIColor redColor] range:NSMakeRange(3, model.num.length)];
    self.leftNum.attributedText = mstr;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
